package com.producerandconsumer;

public class ThreadProducer extends Thread{
    //属性
    private MyStack stack;
    private int i = 0;

    public ThreadProducer(MyStack stack){
        this.stack = stack;
    }


    @Override
    public void run() {

        while (true){
            i = i +1;
            //System.out.println("i---------------" + i);
            stack.push(i);





            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
